<?php
/**
 * Created by PhpStorm.
 * User: zeopean
 * Date: 2015/9/28
 * Time: 17:15
 */
namespace App\Exceptions;

use Exception;

class AdminException extends Exception{

    const NoProjectIdOrFieldId      = 0x01;
    const NoProjectIdOrImageId      = 0x02;
    const NoProjectIdOrTeamId       = 0x03;
    const NoData                    = 0x04;
    const DeleteHandleIsFail        = 0x05;
    const NoInvestorIdOrFieldId     = 0x06;
    const NoInvestorIdOrPhaseId     = 0x07;

    /**
     * @param $code
     * @param array $data
     * @param Exception $previous
     */
    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NoProjectIdOrFieldId:
                $message = trans('exception.admin.no_project_or_field');
                break;
            case self::NoProjectIdOrImageId:
                $message = trans('exception.admin.no-project-or-image');
                break;
            case self::NoProjectIdOrTeamId:
                $message = trans('exception.admin.no-project-or-team');
                break;
            case self::NoData:
                $message = trans('exception.admin.no-team-data');
                break;
            case self::DeleteHandleIsFail:
                $message = trans('exception.admin.deleted.is.fail');
                break;
            case self::NoInvestorIdOrFieldId:
                $message = trans('exception.admin.no-investor-or-field');
                break;
            case self::NoInvestorIdOrPhaseId:
                $message = trans('exception.admin.no-investor-or-phase');
                break;
            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}
